//
//  willBeShownView.m
//  代号：47
//
//  Created by lanou3g on 15/7/1.
//  Copyright (c) 2015年 杨佩璋. All rights reserved.
//

#import "WillBeShownView.h"
#import <UIImageView+WebCache.h>


@interface WillBeShownView ()





@end

@implementation WillBeShownView
-(void)dealloc{
    _model = nil;
    _slideImageView = nil;
    _pubdatelabel = nil;
    _titlelabel = nil;
    _ratinglabel = nil;
    _button = nil;
    [super dealloc];


}
-(instancetype)initWithFrame:(CGRect)frame{

    self = [super initWithFrame:frame];
    if (self) {
        self.slideImageView = [[[SlideImageView alloc]initWithFrame:CGRectMake(self.width/8, self.height/7, self.width - self.width/8 - 50, self.height - self.height/7 - self.height/4) ZMarginValue:5 XMarginValue:10 AngleValue:0.1 Alpha:1000] autorelease];
//        _slideImageView.backgroundColor = [UIColor whiteColor];
//        _slideImageView.delegate = self;
        [self addSubview:_slideImageView];
        self.pubdatelabel = [[[UILabel alloc] initWithFrame:CGRectMake(10, self.height/7 + (self.height - self.height/7 - self.height/4) + 30, self.width/3, 20)] autorelease];
        self.titlelabel = [[[UILabel alloc] initWithFrame:CGRectMake(10, (self.height/7 + (self.height - self.height/7 - self.height/4) + 30) + 20, self.width/1.5, 30)] autorelease];
        self.ratinglabel = [[[UILabel alloc] initWithFrame:CGRectMake(10, self.height/7 + (self.height - self.height/7 - self.height/4) + 10, self.width/3, 20)] autorelease];
        self.button = [UIButton buttonWithType:(UIButtonTypeSystem)];
        _button.frame = CGRectMake(self.width/1.5 + 10 + 20,(self.height/7 + (self.height - self.height/7 - self.height/4) + 30) + 10 , 50, 30);
        [_button setTitle:@"详情" forState:(UIControlStateNormal)];
        _button.backgroundColor = RGBColor(24, 84, 0);
        _button.layer.cornerRadius = 10;
        
        _titlelabel.font = [UIFont boldSystemFontOfSize:18];
        _pubdatelabel.textColor = [UIColor whiteColor];
        _ratinglabel.textColor = [UIColor whiteColor];
        _titlelabel.textColor = [UIColor whiteColor];
        _ratinglabel.font = [UIFont systemFontOfSize:15];
        [_button setTintColor:[UIColor whiteColor]];
                
        [self addSubview:_pubdatelabel];
        [self addSubview:_titlelabel];
        [self addSubview:_ratinglabel];
        [self addSubview:_button];

        
        
    }
    return self;





}

-(void)fzArray:(NSMutableArray *)array{

    self.arrayCZ = [NSMutableArray array];
    _arrayCZ = array;
    
    dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    dispatch_group_t groupQueue = dispatch_group_create();
    
    dispatch_group_async(groupQueue, queue, ^{
        
        for (int i = 0; i < _arrayCZ.count; i++) {
            
            WillBeShownModel *model;
            model = _arrayCZ[i];
            [_slideImageView addImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:model.large]]]];
            
        }

        
    });
    dispatch_group_notify(groupQueue, dispatch_get_main_queue(), ^{
        
        [_slideImageView setImageShadowsWtihDirectionX:2 Y:2 Alpha:0.7];
        [_slideImageView reLoadUIview];
        

    });

    
        

    


    _model = _arrayCZ[0];
    _pubdatelabel.text = _model.pubdate;
    _titlelabel.text = _model.title;
    _ratinglabel.text = [NSString stringWithFormat:@"推荐指数：%@",_model.rating];
  


}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
